//
//  ILBleManager.h
//  IMILabKit
//
//  Created by Roffa Zhou on 2022/4/2.
//

#import <Foundation/Foundation.h>
#import "ILBleUtil.h"

NS_ASSUME_NONNULL_BEGIN

@interface ILBleManager : NSObject
+ (instancetype)shared;

/// 获取蓝牙状态
- (ILCBManagerState)cbManagerState;
/// 开始扫描蓝牙设备,
/// @param timeout 超时时间 秒
- (void)startScan:(short)timeout  callback:(nullable void(^)(BOOL))block ;
/// 开始扫描蓝牙设备
/// @param timeout 超时时间 秒
/// @param allowDuplicates 表示是否重复扫描已发现的设备
/// @param serviceUUIDs UUIDs
/// @param block 开始扫描回调  返回yes表示已执行扫描任务，no表示有错误产生，未执行
- (void)startScan:(short)timeout allowDuplicates:(BOOL)allowDuplicates serviceUUIDs:(NSArray <NSString *>*)serviceUUIDs callback: (nullable void(^)(BOOL))block;
- (void)stopScan;
- (void)disconnect:(ILBlePeripheral*)device;
/// 绑定设备
/// @param device 设备对象
- (void)connectDevice:(ILBlePeripheral*)device  callback:(void(^)(BOOL))block;
/// 发送蓝牙数据
/// @param data 需要发送的数据
/// @param peripheral 蓝牙设备
/// @author rf/2022-03-29
- (void)sendBleMsg:(NSData*)data peripheral:(ILBlePeripheral*)peripheral;
/// 发送加密的蓝牙数据
/// @param data 需要发送的数据
/// @param peripheral 蓝牙设备
/// @author rf/2022-03-29
- (void)sendEncryptBleMsg:(NSData*)data encryptKey:(NSData*)key peripheral:(ILBlePeripheral*)peripheral;
@end

NS_ASSUME_NONNULL_END
